<?php
namespace App\Http\Controllers;

class ToolController extends Controller
{
    public function ListClassified($List,$Fid,$ParentColumn,$ChildColumn)
    {
        $arr=array();
        foreach($List as $k=>$v)
        {
            if($v[$ParentColumn]==$Fid)
            {
                $arr[$v[$ChildColumn]]=$v;
            }
        }
        if(!empty($arr))
        {
            foreach($arr as $k=>$v)
            {
                $temp=$this->ListClassified($List,$v[$ChildColumn],$ParentColumn,$ChildColumn);
                if(!empty($temp))
                {
                    $arr[$k]['List']=array_values($temp);
                }
            }
        }
        return $arr;
    }
}